﻿using HomagGroup.Base.UI;
using Proxy;
using static HomagChina.CCHCS.Utility;

namespace HomagChina.CCHCS.ViewModels
{
    public class BoardReplaceViewModel : NotifyPropertyChangedBase
    {
        private ModifyInfoHandle Handle_ModifyInfo;
        private CommonHandle Handle_Common;
        public RelayCommand ReplaceCommand { get; }

        private string _Title;

        public string Title
        {
            get => _Title;
            set { _Title = value; OnPropertyChanged(); }
        }

        private BoardlibraryModel boardlibraryModel = new BoardlibraryModel();

        public BoardReplaceViewModel(BoardlibraryModel model)
        {
            Title = GetLocalText("Duplicate_found");
            Handle_ModifyInfo = new ModifyInfoHandle();
            Handle_Common = new CommonHandle();
            boardlibraryModel = model;
            ReplaceCommand = new RelayCommand(ReplaceBoardInformation);
        }

        public void ReplaceBoardInformation()
        {
            var msg = Handle_ModifyInfo.ModifyBoardlibraryInfo(boardlibraryModel) ? GetLocalText("Congratulations")
                                                                                  : GetLocalText("Add failed");
            HomagGroup.Base.UI.Windows.MessageBox.Show(msg);
            Handle_Common.CloseDiaLog(Title);
        }
    }
}